<template>
  <div class="child1">
    <h3>子组件1</h3>
    <h4>玩具:{{ toy }}</h4>
    <h4>书籍:{{ book }}本</h4>

    <button @click="minusHouse($parent)">干掉父亲一套房产</button>
  </div>
</template>

<script setup lang="ts" name="Child1">
import { ref } from "vue";

let toy = ref("变形金刚");
let book = ref(3);

function minusHouse(parent: any) {
  console.log(parent);
  // 这里不需要.value 因为 parent是 Proxy对象，house虽然是ref但是他在parent里面，你直接可以拿到house的值
  parent.house -= 1;
}

defineExpose({ toy, book });
</script>

<style scoped>
.child1 {
  margin-top: 20px;
  background-color: skyblue;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 0 10px black;
}
</style>
